package com.UnionPayCenter.mapper;

import com.UnionPayCenter.base.MyMapper;
import com.UnionPayCenter.entity.CouponDeliverRecords;
import com.UnionPayCenter.entity.CouponEntity;
import com.UnionPayCenter.entity.CouponUseRecords;
import com.UnionPayCenter.entity.UserCouponEntity;
import com.UnionPayCenter.entity.vo.ExpiringUserCouponVo;
import com.UnionPayCenter.entity.vo.UserCouponVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository
@Mapper
public interface CouponMapper extends MyMapper<CouponEntity> {

    List<CouponEntity> selectList(@Param("shopId")Integer shopId, @Param("disName")String disName, @Param("disType")String disType,@Param("validTag")String validTag );

    List<UserCouponVo> selectUserCouponList(@Param("shopId")Integer shopId, @Param("mobile")String mobile, 
            @Param("stArray")String[] stArray, @Param("userId")Integer userId, @Param("isBackend")String isBackend, 
            @Param("disType")String disType, @Param("startTime")Date startTime, @Param("endTime")Date endTime);

    int insertUserCoupon(@Param("userCouponEntity")UserCouponEntity userCouponEntity);

    int consumptionCoupon(@Param("userCoupon")UserCouponEntity userCoupon);

    UserCouponVo getUserCouponByDisId(@Param("userId")Integer userId, @Param("disId")String disId);

    int getUserCouponCount(@Param("userId")Integer userId, @Param("shopId")Integer shopId, @Param("status")String status);

    List<UserCouponEntity> getExpiredCouponList(@Param("shopId")Integer shopId, @Param("now")Date now, @Param("status")String status);

    int updateExpiredCoupon(@Param("id")Integer id, @Param("status")String status);

    List<CouponDeliverRecords> selectCouponDeliverRecords(@Param("shopId")Integer shopId, @Param("mobile")String mobile, 
            @Param("disType")String disType, @Param("startTime")String startTime, @Param("endTime")String endTime);

    List<CouponUseRecords> selectCouponUseRecords(@Param("shopId")Integer shopId, @Param("mobile")String mobile, 
            @Param("disType")String disType, @Param("startTime")String startTime, @Param("endTime")String endTime);

    List<ExpiringUserCouponVo> selectExpiringUserCoupon(@Param("expireDate")String expireDate);

}
